<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('修改字段检核规则')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-manage-edit"
			th:object="${verifyFieldRuleManage}">
			<input name="checkRuleId" th:field="*{checkRuleId}" type="hidden">
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">系统代码：</label>
				<div class="col-sm-8">
					<div class="input-group">
						<input type="hidden" id="sysId" name="sysId" th:field="*{sysId}" />
						<input name="sysCode" th:field="*{sysCode}"
							onclick="selectMdSysModel()" id="sysCode" type="text"
							placeholder="请选择系统" class="form-control"> <span
							class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">系统名称：</label>
				<div class="col-sm-8">
					<input id="sysName" th:field="*{sysName}" name="sysName"
						class="form-control" readonly="true" type="text" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">模块代码：</label>
				<div class="col-sm-8">
					<div class="input-group">
						<input type="hidden" id="moduleId" th:field="*{moduleId}"
							name="moduleId" /> <input name="moduleCode"
							th:field="*{moduleCode}" onclick="selectMdModule()"
							id="moduleCode" type="text" placeholder="请选择功能模块"
							class="form-control"> <span class="input-group-addon"><i
							class="fa fa-search"></i></span>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">模块名称：</label>
				<div class="col-sm-8">
					<input id="moduleName" name="moduleName" th:field="*{moduleName}"
						class="form-control" readonly="true" type="text" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">表代码：</label>
				<div class="col-sm-8">
					<div class="input-group">
						<input type="hidden" id="tableId" name="tableId"
							th:field="*{tableId}" /> <input name="tableCode"
							onclick="selectMdTable()" th:field="*{tableCode}" id="tableCode"
							type="text" placeholder="请选择表代码" class="form-control"> <span
							class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">表名称：</label>
				<div class="col-sm-8">
					<input id="tableName" name="tableName" th:field="*{tableName}"
						class="form-control" readonly="true" type="text" />
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">字段代码：</label>
				<div class="col-sm-8">
					<input name="fieldCode" th:field="*{fieldCode}"
						class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">字段名称：</label>
				<div class="col-sm-8">
					<input name="fieldName" th:field="*{fieldName}"
						class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">字段说明：</label>
				<div class="col-sm-8">
					<input name="fieldRemark" th:field="*{fieldRemark}"
						class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">字段类型：</label>
				<div class="col-sm-8">
					<input name="fieldType" th:field="*{fieldType}"
						class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">规则类型</label>
				<div class="col-sm-8">
					<select name="ruleType" class="form-control m-b"
						th:with="type=${@dict.getType('rule_type')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
							th:value="${dict.dictValue}" th:field="*{ruleType}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">规则：</label>
				<div class="col-sm-8">
					<input name="rule" th:field="*{rule}" class="form-control"
						type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">规则说明：</label>
				<div class="col-sm-8">
					<textarea name="ruleRemark" class="form-control">[[*{ruleRemark}]]</textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var prefix = ctx + "verify/rule"
		$("#form-manage-edit").validate({
			focusCleanup : true
		});

		function submitHandler() {
			if ($.validate.form()) {
				$.operate.save(prefix + "/edit", $('#form-manage-edit')
						.serialize());
			}
		}

		/* 选择系统 */
		function selectMdSysModel() {
			debugger;
			var url = prefix + "/showMdSysList";
			var options = {
				title : '选择系统',
				width : "600",
				url : url,
				callBack : doSubmitMdSysData
			};
			$.modal.openOptions(options);
		}

		function doSubmitMdSysData(index, layero) {
			debugger;
			var tableObj = layero.find("iframe")[0].contentWindow.$.table;
			var sysId = tableObj.selectColumns("sysId")[0];
			var sysCode = tableObj.selectColumns("sysCode")[0];
			var sysName = tableObj.selectColumns("sysName")[0];
			$("#sysId").val(sysId);
			$("#sysCode").val(sysCode);
			$("#sysName").val(sysName);
			layer.close(index);
		}

		/* 选择功能模块 */
		function selectMdModule() {
			debugger;
			var sysId = $("#sysId").val();
			var url = prefix + "/showMdModuleList/" + sysId;
			var options = {
				title : '选择功能模块',
				width : "600",
				url : url,
				callBack : doSubmitSelectModelData
			};
			$.modal.openOptions(options);
		}

		function doSubmitSelectModelData(index, layero) {
			debugger;
			var tableObj = layero.find("iframe")[0].contentWindow.$.table;
			var moduleId = tableObj.selectColumns("moduleId")[0];
			var moduleCode = tableObj.selectColumns("moduleCode")[0];
			var moduleName = tableObj.selectColumns("moduleName")[0];
			$("#moduleId").val(moduleId);
			$("#moduleCode").val(moduleCode);
			$("#moduleName").val(moduleName);
			layer.close(index);
		}

		//选择表代码  
		function selectMdTable() {
			debugger;
			var moduleId = $("#moduleId").val();
			var url = prefix + "/showMdTableList/" + moduleId;
			var options = {
				title : '选择表模块',
				width : "600",
				url : url,
				callBack : doSubmitSelectTableModeData
			};
			$.modal.openOptions(options);
		}
		function doSubmitSelectTableModeData(index, layero) {
			debugger;
			var tableObj = layero.find("iframe")[0].contentWindow.$.table;
			var tableId = tableObj.selectColumns("tableId")[0];
			var tableCode = tableObj.selectColumns("tableCode")[0];
			var tableName = tableObj.selectColumns("tableName")[0];
			$("#tableId").val(tableId);
			$("#tableCode").val(tableCode);
			$("#tableName").val(tableName);
			layer.close(index);
		}
	</script>
</body>
</html>